// 获取用户定位
function getLocation() {
	return new Promise((resolve, reject) => {
		if (navigator.geolocation) {
			navigator.geolocation.getCurrentPosition(
				position => resolve(position.coords),
				() => reject(new Error('位置获取失败，请确保打开定位或权限后重试')),
				{ timeout: 5000 }
			)
		} else {
			reject(new Error('位置获取失败，请确保打开定位或权限后重试'))
		}
	})
}

export default getLocation
